import ViewUI from 'view-ui-plus'
import VueAwesomeSwiper from 'vue-awesome-swiper'
import { Vue, createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import VueHttpPlugin from './libs/vue-http-plugin'
import 'view-ui-plus/dist/styles/viewuiplus.css'
import 'swiper/swiper.less'
import './libs/filter'

const app = createApp(App)

app.use(VueAwesomeSwiper)
app.use(ViewUI)
app.use(VueHttpPlugin)

app.config.productionTip = false
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App),
  mounted() {
    this.hashChange()
  },
  methods: {
    // vue-router 兼容ie
    hashChange: function () {
      let self = this
      if (
        '-ms-scroll-limit' in document.documentElement.style
          && '-ms-ime-align' in document.documentElement.style
      ) {
        window.addEventListener('hashchange', () => {
          let currentPath = window.location.hash.slice(1)
          if (self.$route.path !== currentPath) {
            self.$router.push(currentPath)
          }
        }, false)
      }
    },
  },
})
